package com.huey.utils.thread;

import com.google.common.collect.Lists;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;


/**
 * @author xubo
 * @date 2022/12/6 9:25
 */
@RestController
@RequestMapping("thread")
public class TestThreadController {

    @GetMapping(value = "run")
    public String run() {
        List<Integer> list= Lists.newArrayList();
        for(int i=0;i<100;i++){
            list.add(i);
        }


        for(Integer a:list){
            List<Integer> newList = new ArrayList<>();
            try {
                ThreadPoolUtils.getFixThreadPoolExecutor().execute(() -> newList.add(a));
            }catch (Exception e){
                System.out.println(e.getMessage());
            }
            System.out.println("测试："+newList.size());
        }
        return "do something you like ------";
    }
}
